package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.RepairManageItemBean;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.StringCodeUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-18  16:03
 * @Description: 车辆维护和车辆保养的适配器
 */
public class RepairHistoryListAdapter extends BaseQuickAdapter<RepairManageItemBean, BaseViewHolder> {

    public RepairHistoryListAdapter(int layoutResId, @Nullable List<RepairManageItemBean> data) {
        super(layoutResId, data);

        addChildClickViewIds(R.id.textviewcontanthistory);

        //设置点击事件；
//        addChildLongClickViewIds(//
//                R.id.textviewrepairintostation//
//                ,R.id.textviewbookingchange,//
//                R.id.textviewbookingcancel);//

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, RepairManageItemBean repairManageItemBean) {

        if (repairManageItemBean != null) {

            //设置item数据；
            //获取名字
            String carNumber = repairManageItemBean.getCarNo();

            //销售顾问的名字
            String managerName = repairManageItemBean.getManagerName();

            //获取联系人姓名
            String personName = repairManageItemBean.getCustomerName();

            //获取这个条目的状态
            String personPhone = repairManageItemBean.getPhone();

            //选中的预约时间
            String timeChoose = repairManageItemBean.getAppointmentTime();

            //客户的意图标签，是要【预约维修】 还是要【预约保养】
            String typeRepair = repairManageItemBean.getAppointmentTypeInfo();

            //该条目的分配状态
            String itemState = repairManageItemBean.getHandleStatusInfo();

            //findViews
            //勾选按钮：
//            CheckBox checkBoxInRepairManage = (CheckBox) baseViewHolder.getView(R.id.checkboxinrepairmanage);

            //车牌号信息
            TextView textViewCarnumberName = (TextView) baseViewHolder.getView(R.id.textviewcarnumbernamehistory);

            //顾问的姓名
            TextView textViewContManagerNameHistory = (TextView) baseViewHolder.getView(R.id.textviewcontmanagernamehistory);

            //车辆的 维修还是保养的区分标签
            RoundTextView textViewRepairTypeTag = (RoundTextView) baseViewHolder.getView(R.id.textviewrepairtypetaghistory);
            //改单子的分配状态
            TextView textViewRepairAssignedState = (TextView) baseViewHolder.getView(R.id.textviewrepairassignedstatehistory);
            //真实的联系人姓名？
            TextView textViewContantPerson = (TextView) baseViewHolder.getView(R.id.textviewcontantpersonhistory);
            //真是的联系人电话信息
            TextView textViewContant = (TextView) baseViewHolder.getView(R.id.textviewcontanthistory);
            //客户的预约时间
            TextView textViewBookingTime = (TextView) baseViewHolder.getView(R.id.textviewbookingtimehistory);

            //已进站的 按钮内容？
//            RoundTextView textViewRepairIntoStation = (RoundTextView) baseViewHolder.getView(R.id.textviewrepairintostation);
            //按钮的 改预约  按钮
//            RoundTextView textViewBookingChange = (RoundTextView) baseViewHolder.getView(R.id.textviewbookingchange);
            //取消预约按钮
//            RoundTextView textViewBookingCancel = (RoundTextView) baseViewHolder.getView(R.id.textviewbookingcancel);

            //车牌名称
            CommUtils.setText(textViewCarnumberName, carNumber);
            //销售顾问名称
            CommUtils.setText(textViewContManagerNameHistory, managerName);
            //标签名称
            CommUtils.setText(textViewRepairTypeTag, typeRepair);
            //获取联系人姓名
            CommUtils.setText(textViewContantPerson, personName);
            //联系人电话
//            CommUtils.setText(textViewContant, personPhone);
            CommUtils.setText(textViewContant, StringCodeUtils.mobileEncrypt(personPhone));
            //预约时间
            CommUtils.setText(textViewBookingTime, timeChoose);
            //该预约单子的状态-分配状态
            CommUtils.setText(textViewRepairAssignedState, itemState);

            //三个按钮的点击状态

        }

    }

}
